<?php

namespace zhtfrontend\models\datas;

use common\models\datas\Type;
use Yii;

/**
 * This is the model class for table "{{%orders_type}}".
 *
 * @property integer $id
 * @property integer $orders_id
 * @property integer $type_id
 * @property string $amount
 * @property integer $quantity
 * @property string $weight
 */
class OrdersType extends \zhtfrontend\components\bases\BaseModel
{
    public  $items;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%orders_type}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['orders_id', 'type_id', 'quantity'], 'integer'],
            [['amount', 'weight'], 'number']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('zhtfrontend', '自增编码'),
            'orders_id' => Yii::t('zhtfrontend', '订单id'),
            'type_id' => Yii::t('zhtfrontend', '商品类型id'),
            'amount' => Yii::t('zhtfrontend', '商品价格'),
            'quantity' => Yii::t('zhtfrontend', '商品数量'),
            'weight' => Yii::t('zhtfrontend', '商品重量(单位kg)'),
        ];
    }

    public function getType(){
        return $this->hasOne(Type::className(),['id'=>'type_id']);
    }

    public function getOrders(){
        return $this->hasOne(Orders::className(),['id'=>'orders_id']);
    }
}
